<template>
  <div class="view-container">
    <div class="main-content">
      <div class="list-container">
        <el-tabs
          v-model="activeName"
          @tab-click="handleClick"
        >
          <el-tab-pane
            label="终端资质"
            name="terminalList"
          />
          <el-tab-pane
            label="代理资质"
            name="agentList"
          />
          <el-tab-pane
            label="配送商资质"
            name="distributorList"
          />
          <el-tab-pane
            label="商销客户资质"
            name="sellerList"
          />
        </el-tabs>
        <component :is="activeName" />
      </div>
    </div>
  </div>
</template>

<script>
import { defineAsyncComponent, reactive, toRefs } from 'vue'
import { useRoute, useRouter } from 'vue-router'

export default {
  components: {
    terminalList: defineAsyncComponent(() => import('./terminalList.vue')),
    agentList: defineAsyncComponent(() => import('./agentList.vue')),
    distributorList: defineAsyncComponent(() =>
      import('./distributorList.vue')
    ),
    sellerList: defineAsyncComponent(() => import('./sellerList.vue')),
  },
  setup(props, context) {
    const route = useRoute()
    const router = useRouter()
    var datas = reactive({
      activeName: route.query.tabs || 'terminalList',
    })
    const handleClick = (tab, event) => {
      router.push({
        name: 'customerQualification',
        query: {
          tabs: tab.props.name,
        },
      })
    }
    return {
      ...toRefs(datas),
      handleClick,
    }
  },
}
</script>

<style>
</style>
